//  WordsAppDelegate.h
//  Words
//Abstract: The main application delegate for the application.  Contains most
//of the important code for managing the information.
//
//  Created by Mathieu on 9/06/06.
//  Copyright __MyCompanyName__ 2006 . All rights reserved.

#import <Cocoa/Cocoa.h>
#import <ObjectiveFlickr/ObjectiveFlickr.h>
#import <Foundation/Foundation.h>

@interface NSFileManager (PRAdditions)

- (NSString *)findSystemFolderType:(int)folderType forDomain:(int)domain;

@end

//#import "NSFileManagerPRAdditions.h"

@protocol LookupMethods
-(oneway void)defineWords:(NSArray *)words inDictionaries:(NSArray *)dictionaries;
-(oneway void)connectToDictionaries:(NSArray *)dicts;
@end

@class WordUtilities;
@class LanguageMO;
@class InUseDictController;
@class Group;
@class GroupsArrayController;
@class BubbleController;
@class ControllerData;
@class WordMO;

@interface WordsAppDelegate : NSObject 
{
	//networks
 	//default Core Data stack
	NSManagedObjectModel			*managedObjectModel;
    NSManagedObjectContext			*managedObjectContext;
	NSPersistentStoreCoordinator    *persistentStoreCoordinator;
	NSURL                           *defaultStoreURL;
	NSURL							*internalStoreURL; //some place to keep our internal data
	
	
	//controllers
	IBOutlet NSArrayController *wordArrayController;
	IBOutlet NSArrayController *definitionArrayController;
	IBOutlet NSArrayController *languageArrayController;
	IBOutlet InUseDictController *inUseDictController;
	IBOutlet GroupsArrayController *groupArrayController;
	IBOutlet NSArrayController *transLangArrayController;
	IBOutlet NSArrayController *allWords;
	
	IBOutlet BubbleController *bubbleController;
	
	//saving selections between launches
	NSMutableDictionary *languageGroupControllerSelectionSaver;
	ControllerData *controllerDataEntity;

	//windows and views
	IBOutlet NSWindow *window;
	IBOutlet NSWindow *miniWindow;
	IBOutlet NSTextField *windowSummaryString; 
	IBOutlet NSTabView *definitionsTabView;
	IBOutlet NSTabView *mainWindowTabView;
	
	IBOutlet NSProgressIndicator *definitionInProgressIndicator;
	
	//Flickr
 	OFFlickrContext* flickrContext;
	NSArray *photos;
	
	WordUtilities *wordUtilities; //this object handles word  stuff
	IBOutlet NSTextField *newLanguageInfoStringInAddLanguageView;
	id lookerupperer;
}

- (void)makeWindowActive;

-(IBAction)defineAllWords:(id)sender;
-(void)stopDefiningAllWordsAnimation;

- (LanguageMO *)currentlySelectedLanguage;
- (LanguageMO *)currentlySelectedTransLanguage;

- (Group *)currentlySelectedGroup;
- (InUseDictController *)inUseDictController;
- (void)setMainWindowTabToMainView;

// tab controls
- (IBAction)returnToMainTab:(id)sender;
- (IBAction)openGamesTab:(id)sender;
- (IBAction)openLanguageAndContextCreatorTab:(id)sender;


- (NSMutableDictionary *)languageGroupControllerSelectionSaver;
- (ControllerData *)controllerDataEntityAccess;

- (id)lookerupperer;

-(IBAction)exportWordsAndDefsToSQLOfSelectedLanguage:(id)sender;
-(IBAction)exportLanguagesToSQL:(id)sender;

//flickr
- (OFFlickrContext*)flickrContext;


// accessor for the default managed object context and coordinator
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator;
- (NSManagedObjectContext *)managedObjectContext;
- (NSManagedObjectModel *)managedObjectModel;

- (IBAction)openAlternativeViewTab:(id)sender;

-(IBAction)defineSelectedWord:(id)sender;

	// accessors for the main persistent stores
//- (id)primaryStore;
//- (id)inMemoryStore;

	// accessor for the Library SmartGroup that is the owner for all editable recipes
//- (NSManagedObject *)libraryGroup;
//
//	// actions to inspect and save items
//- (void)saveAction:(id)sender;
//- (void)inspect:(NSArray *)selectedObjects;
//- (void)saveSelectedWordAs:(id)sender;	

// Lookup methods
-(bool)defineWord:(WordMO *)word; //this only uses local dictionaries.
-(IBAction)attemptToDefineAllWordsInWordArray:(id)sender;
-(NSSet *)inUseDictionariesForLanguage:(LanguageMO *)language;
-(NSMutableSet *)internalDictionaries;
-(void)defineTheseWords:(NSArray *)words inDictionaries:(NSArray *)dictionaries;

-(BubbleController *)bubbleController;
-(NSArray *)transLangsDictionaries;
- (void)setServer:(id)anObject;



@end
